package com.travel.travelServer.utils;

public class ResponseData<E> {

    // 响应code
    private Integer code;

    // 响应消息
    private String message;

    // 响应数据
    private E data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public E getData() {
        return data;
    }

    public void setData(E data) {
        this.data = data;
    }

    public static <E> ResponseData<E> success(E data){
        ResponseData<E> responseData = new ResponseData<>();
        responseData.setCode(200);
        responseData.setMessage("成功");
        responseData.setData(data);
        return responseData;
    }

    public static <E> ResponseData<E> fail(Integer code, String message){
        ResponseData<E> responseData = new ResponseData<>();
        responseData.setCode(code);
        responseData.setMessage(message);
        return responseData;
    }
}
